package aircraft_war;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;

public class ImageDemo extends JPanel{
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        BufferedImage bg=null;
        //读取图片
        try {
            bg= ImageIO.read(ImageDemo.class.getResourceAsStream("Image/background.png"));
        } catch (IOException e) {
            e.printStackTrace();
        }

        //显示图片
        g.drawImage(bg,0,0,this);

        //显示文字
        Font font=new Font("黑体",Font.BOLD,15);
        g.setFont(font);
        Color c=Color.BLACK;
        g.setColor(c);
        g.drawString("Score:",5,20);
        g.drawString("Life:",5,50);



    }
}
